function pathways = load_gmt(gmtFilePath)
% Define the path to your .gmt file
gmtFilePath = 'c2.cp.v2023.2.Hs.symbols.gmt';

fid = fopen(gmtFilePath, 'r');

pathways = {};

% 逐行读取文件
while ~feof(fid)
     % 读取单行
    tline = fgetl(fid);
    
    % 使用tab键分割行
    lineParts = strsplit(tline, '\t');
    
    % 检查是否超出限制
    if length(lineParts{2}) > 63
        % 分割为多个字符串
        lineParts{2} = splitLongString(lineParts{2}, 63);
    end
    
    % 添加通路信息到cell数组
    pathways{end+1} = lineParts;
end

% 关闭文件
fclose(fid);
end


function substrings = splitLongString(str, maxLength)
    substrings = {};
    while length(str) > maxLength
        % 
        spaceIdx = find(str(1:maxLength) == ' ', 1, 'last');
        if isempty(spaceIdx)
            % 
            splitIdx = maxLength;
        else
            % 
            splitIdx = spaceIdx;
        end
        % 
        substrings{end+1} = str(1:splitIdx);
        % 
        str = str(splitIdx+1:end);
    end
    % 
    if ~isempty(str)
        substrings{end+1} = str;
    end
end